package com.bzyd.cloud.controller;

import com.bzyd.cloud.pojo.Product;
import com.bzyd.cloud.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ProductController
 * Created by Xianyue Dang on 2021/4/28
 */
@RestController
@Slf4j
public class ProductController {

    @Autowired
    private ProductService productService;

    //商品信息查询
    @RequestMapping("/product/{pid}")
    public Product product(@PathVariable("pid")Integer pid){
        log.info("接下来要进行{}号商品信息的查询",pid);
        Product product = productService.findByPid(pid);
        return product;
    }

    @RequestMapping("/product/reduceInventory")
    public void reduceInventory(Integer pid, int num){
        productService.reduceInventory(pid,num);
    }
}
